//
//  RxLearningCVC.swift
//  CooperSwift_Example
//
//  Created by 计海峰 on 2021/5/8.
//  Copyright © 2021 CocoaPods. All rights reserved.
//

import UIKit
import RxSwift

class RxLearningCVC: UIViewController {
    
    let disposeBag = DisposeBag()


    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
        
//        let ob = Observable<Any>.create { (observe) -> Disposable in
//            observe.onNext("xxx")
//            return Disposables.create {
//                debugPrint("销毁释放了")
//            }
//        }
//
//        ob.subscribe (
//            onNext: { anything in print("订阅到了:\(anything)")},
//            onError: { error in  print("订阅到了:\(error)") },
//            onCompleted: { print("完成了") }) {
//            print("销毁了")
//        }

        // 1:初始化序列
        let publishSub = PublishSubject<Int>()
        // 2:发送响应序列
        publishSub.onNext(1)
        // 3:订阅序列
        publishSub.subscribe { print("订阅到了:",$0)}
            .disposed(by: disposeBag)
        // 再次发送响应
        publishSub.onNext(2)
        publishSub.onNext(3)

        // Do any additional setup after loading the view.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destination.
        // Pass the selected object to the new view controller.
    }
    */

}
